package com.quectel.core.config;

import com.quectel.util.aspect.lock.DistributedLockMethodInterceptor;
import com.quectel.util.aspect.lock.DistributedLockPointCutAdvisor;
import com.quectel.util.client.redis.RedisClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * lock切面配置
 *
 * @author caolu
 * @email louis.cao@quectel.com
 * @date 2023-11-28 14:19:00
 */
@Configuration
public class LockAspectConfig {
    /**
     * 定义拦截器
     *
     * @param redisClient
     * @return
     */
    @Bean
    public DistributedLockMethodInterceptor distributedLockMethodInterceptor(RedisClient
                                                                                     redisClient) {
        return new DistributedLockMethodInterceptor(redisClient);
    }

    /**
     * 定义切点,并绑定拦截器
     *
     * @param distributedLockMethodInterceptor
     * @return
     */
    @Bean
    public DistributedLockPointCutAdvisor distributedLockPointCutAdvisor(DistributedLockMethodInterceptor
                                                                                 distributedLockMethodInterceptor) {

        return new DistributedLockPointCutAdvisor(distributedLockMethodInterceptor);

    }
}
